import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt

img = cv.imread('perspective.jpg')

rows, cols, ch = img.shape
pts1 = np.float32([[290, 139], [362, 121], [331, 209], [409, 191]])
pts2 = np.float32([[0, 0], [300, 0], [0, 300], [300, 300]])
M = cv.getPerspectiveTransform(pts1, pts2)
dst = cv.warpPerspective(img, M, (300, 300))  //

cv.imshow('img', img)
cv.imshow('dst', dst)
cv.waitKey(0)